<template>
	<div>
		<el-form ref="form" :model="form" label-width="100px">

			<el-form-item label="护士姓名" prop="nurseName">
				<el-input v-model="form.nurseName"></el-input>
			</el-form-item>
			<el-form-item label="工号" prop="nurseNumber">
				<el-input v-model="form.nurseNumber"></el-input>
			</el-form-item>
			<el-form-item label="工作内容" prop="jobContent">
				<el-input v-model="form.jobContent"></el-input>
			</el-form-item>
			<el-form-item label="提交时间" prop="submissionTime">
				<el-date-picker v-model="form.submissionTime" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
				:style="{width: '100%'}" placeholder="请输入时间" clearable>
				</el-date-picker>
			</el-form-item>
			
			
			 
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'WorkDiaryEdit',
		components: {

		},
		props: [
			'showEdit',
			'diaryId',
			'editid'
		],
		data() {
			return {
				form: {
					diaryId: '',
					userName: '',
					nurseNumber: '',
					jobContent: '',
					submissionTime: ''
				},
				// isupdate: false,
				url: '/workDiary/save',
				registerlevel: [],
				depts: [],
			}
		},
		created() {
			// this.init()
			console.log("this.editid:" + this.editid)
			if (this.editid) {


	
				this.axios.get('/workDiary/toedit', response => {
					console.log(response.obj);
					this.form.diaryId = response.obj.diaryId
					// console.log(this.form.id);
					this.form.nurseName = response.obj.nurseName
					this.form.nurseNumber = response.obj.nurseNumber
					this.form.jobContent = response.obj.jobContent
					this.form.submissionTime = response.obj.submissionTime
				}, {
					id: this.editid
				})
			}
		},
		methods: {
			save() {
				this.$refs['form'].validate((valid) => {
					if (valid) {
						this.axios.post(this.url, response => {
							// 子组件要改变父组件的值
							this.$emit('update:show', false)
							this.$emit('getData')
						}, this.form)
					}
				})
			}

		}
	}
</script>

<style>
</style>
